package com.acwing.partition3;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/13 10:42
 */
public class AC243一个简单的整数问题2_树状数组 {

    private static final int N = 100010;
    //tr 数组是原始数组的差分数组d[i]的树状数组，tri 数组是原始数组的差分数组乘以i即 i*d[i] 的树状数组
    private static int[] a = new int[N];
    private static long[] tr = new long[N], tri = new long[N];

    private static int n = 0, m = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        ss = reader.readLine().split(" ");
        for (int i = 1; i <= n; i++) a[i] = Integer.parseInt(ss[i - 1]);
        //构建树状数组
        for (int i = 1; i <= n; i++) {
            int d = a[i] - a[i - 1];
            add(tr, i, d);
            add(tri, i, (long) d * i);
        }
        while (m-- > 0) {
            ss = reader.readLine().split(" ");
            int l = Integer.parseInt(ss[1]), r = Integer.parseInt(ss[2]);
            if (ss[0].charAt(0) == 'Q') {
                long ans = sum(r) - sum(l - 1);
                writer.write(ans + "\n");
            } else {
                int d = Integer.parseInt(ss[3]);
                //a[l] += d
                add(tr, l, d);
                add(tri, l, (long) l * d);
                //a[r+1] -= d;
                add(tr, r + 1, -d);
                add(tri, r + 1, (long) (r + 1) * -d);
            }
        }
        writer.flush();
    }

    private static long sum(int x) {
        return ask(tr, x) * (x + 1) - ask(tri, x);
    }

    private static long ask(long[] tr, int x) {
        long res = 0;
        for (int i = x; i != 0; i -= lowbit(i)) res += tr[i];
        return res;
    }

    private static void add(long[] tr, int x, long k) {
        for (int i = x; i <= N; i += lowbit(i)) tr[i] += k;
    }

    private static int lowbit(int x) {
        return x & -x;
    }
}
